package com.mxpio.erp.plm.service.impl;

import com.mxpio.erp.common.plm.entity.ProjectInfoChange;
import com.mxpio.erp.common.plm.entity.ProjectInfoChangeRecord;
import com.mxpio.erp.common.plm.entity.ProjectInfoEnd;
import com.mxpio.erp.common.plm.service.ProjectInfoChangeRecordService;
import com.mxpioframework.security.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 *  项目信息变更记录表Service接口实现
 * @author qb
 * @since 2024-2-19
 * @version 0.0.1
 */
@Service
public class ProjectInfoChangeRecordServiceImpl extends BaseServiceImpl<ProjectInfoChangeRecord> implements ProjectInfoChangeRecordService {
    /**
     * 变更记录-项目终止
     * @param projectInfoEnd
     */
    @Override
    @Transactional
    public void changeRecord(ProjectInfoEnd projectInfoEnd, String remark) {
        ProjectInfoChangeRecord changeRecord = new ProjectInfoChangeRecord();
        changeRecord.setChangeNumber(projectInfoEnd.getBizNo());
        changeRecord.setProCode(projectInfoEnd.getProCode());
        changeRecord.setChangeType(projectInfoEnd.getChangeType());
        changeRecord.setChangeReason(projectInfoEnd.getReason());
        changeRecord.setChangeUser(projectInfoEnd.getApplicant());
        changeRecord.setChangeTime(new Date());
        changeRecord.setRemark(remark);
        this.save(changeRecord);
    }

    /**
     * 变更记录-变更内容
     * @param projectInfoChange
     * @param remark
     */
    @Override
    @Transactional
    public void changeRecordSubstance(ProjectInfoChange projectInfoChange, String remark) {
        ProjectInfoChangeRecord changeRecord = new ProjectInfoChangeRecord();
        changeRecord.setChangeNumber(projectInfoChange.getBizNo());
        changeRecord.setProCode(projectInfoChange.getProCode());
        changeRecord.setChangeType(projectInfoChange.getChangeType());
        changeRecord.setChangeReason(projectInfoChange.getReason());
        changeRecord.setChangeUser(projectInfoChange.getApplicant());
        changeRecord.setChangeTime(new Date());
        changeRecord.setRemark(remark);
        this.save(changeRecord);

    }

}
